<?php
class Admin_Table_Privilege extends Apk_Db_Table
{
    protected $_name = 'accounts_privileges';

    protected $_dependentTables = array('Admin_Table_RulePrivilege');

	protected $_referenceMap    = array(
                                        'Resource' => array(
                                            'columns'           => array('resource_id'),
                                            'refTableClass'     => 'Admin_Table_Resource',
                                            'refColumns'        => array('id')
                                        ));


    public function GetList()
    {
		$sel = $this->getAdapter()->select()
			->from($this->_name, array('id', 'name_full', 'name'))
			->order('norder');

		return $this->GetList($sel)->toArray();
    }

	public function insert(array $data, $user_id)
    {
    	$data['add_date'] = time();
    	$data['add_user_id'] = $user_id;
    	$data['modify_user_id'] = $user_id;

        return parent::insert($data);
    }

    public function remove($id)
    {
        return parent::delete('id = '.$id);
	}
}
?>